package com.studio77.guessLyric.util;

import android.content.SharedPreferences.Editor;

import com.studio77.guessLyric.core.GameSystem;

public class ShareSettingUtil {

	/**
	 * 获取String对象
	 * 
	 * @param key
	 * @return
	 */
	public static String getStringSetting(String key) {
		return GameSystem.SharedSettings.getString(key, "null");
	}

	/**
	 * 保存文本
	 * 
	 * @param key
	 * @param content
	 */
	public static void storeStringSetting(String key, String content) {
		Editor editor = GameSystem.SharedSettings.edit();
		editor.putString(key, content);
		editor.commit();
	}

	public static void storeIntSetting(String key, int content) {
		Editor editor = GameSystem.SharedSettings.edit();
		editor.putInt(key, content);
		editor.commit();
	}

	public static int getIntSetting(String key, int defaultValue) {
		try {
			return GameSystem.SharedSettings.getInt(key, defaultValue);
		} catch (Exception e) {
			return defaultValue;
		}
	}

	public static void storeBooleanSetting(String key, Boolean content) {
		Editor editor = GameSystem.SharedSettings.edit();
		editor.putBoolean(key, content);
		editor.commit();
	}

	public static boolean getBooleanSetting(String key, boolean defaultValue) {
		try {
			return GameSystem.SharedSettings.getBoolean(key, defaultValue);
		} catch (Exception e) {
			return defaultValue;
		}
	}
}
